import {
  AccountParams,
  OrgListItem,
  MenuParams,
  RoleParams,
  RolePageParams,
  MenuListGetResultModel,
  OrgListGetResultModel,
  AccountListGetResultModel,
  RolePageListGetResultModel,
  RoleListGetResultModel,
} from './model/systemModel';
import { http } from '@/utils/http/axios';

enum Api {
  AccountList = '/system/getAccountList',
  OrgList = '/authority/org/trees?parentId=0',
  setRoleStatus = '/system/setRoleStatus',
  MenuList = '/system/getMenuList',
  RolePageList = '/system/getRoleListByPage',
  GetAllRoleList = '/authority/roles/query_all',
}

export const getAccountList = (params: AccountParams) =>
  http.request<AccountListGetResultModel>({ url: Api.AccountList, params });

export const getOrgList = (params?: OrgListItem) =>
  http.request<OrgListGetResultModel[]>({ url: Api.OrgList, params });

export const getMenuList = (params?: MenuParams) =>
  http.request<MenuListGetResultModel>({ url: Api.MenuList, params });

export const getRoleListByPage = (params?: RolePageParams) =>
  http.request<RolePageListGetResultModel>({ url: Api.RolePageList, params });

export const getAllRoleList = (params?: RoleParams) =>
  http.request<RoleListGetResultModel>({ url: Api.GetAllRoleList, params });

export const setRoleStatus = (id: number, status: string) =>
  http.request({ url: Api.setRoleStatus, params: { id, status } });
